function E = compute_Roberts( P )


X=P;
x=double(X);
[C,L]=size(x);


%必要的变量声明
out = zeros(C,L);



factor = 1;
limit =30 ;
for I = 1:C-1
    for J = 2:L-1
        result1 = x(I,J)-x(I+1,J-1); %利用差分模板计算梯度
        result2 = x(I,J)-x(I+1,J+1);
        result = max(result1, result2);
        out(I,J) = result/factor;
        if out(I,J) <1
            out(I,J) = 1;
        end
        if out(I,J) >256
            out(I,J) = 256;
        end
    end
end
%二值化
for I = 1:C
    for J = 1:L
        if out(I,J)>=limit
            out(I,J) = 256;
        else
            out(I,J) = 1;
        end
    end
end


E = uint8(out)-1;

end